<include file="public/layout" />
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商城设置</h3>
                <h5>分销基本配置</h5>
            </div>
            <ul class="tab-base nc-row">
                <foreach name="group_list" item="v" key="k">
                    <li><a href="{:url('Admin/Distribut.Distribut/index',['inc_type'=> $k])}" <if condition="$k==$inc_type">class="current"</if>><span>{$v}</span></a></li>
                </foreach>
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>若开启分销，普通会员启用默认分销规则，还可以去设置分销商等级设定分销规则</li>
            <li>分销返佣金额每个商品单独设定，原则上不高于商品价格50%</li>
        </ul>
    </div>
    <form method="post" enctype="multipart/form-data" id="handlepost" action="{:url('Admin/Systems.Systems/handle')}">
        <input type="hidden" name="form_submit" value="ok" />
        <div class="ncap-form-default">

            <div id="switch_on_off" >
            <dl class="row">
                <dt class="tit">
                    <label for="distribut_date">分销模式</label>
                </dt>
                <dd class="opt">
                    <select name="pattern" id="distribut_pattern">
                        <option value="0" <if condition="$config['pattern'] eq 0">selected="selected"</if>>按商品设置的分成金额</option>
                        <option value="1" <if condition="$config['pattern'] eq 1">selected="selected"</if>>按订单设置的分成比例</option>
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <label for="distribut_date">返佣级数</label>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <select name="regrade" id="regrade">
                        <option value="0" <if condition="$config['regrade'] eq 0">selected="selected"</if>>返一级</option>
                        <option value="1" <if condition="$config['regrade'] eq 1">selected="selected"</if>>返二级</option>
                        <option value="2" <if condition="$config['regrade'] eq 2">selected="selected"</if>>返三级</option>
                    </select>
                </dd>
            </dl>
            <dl class="row"><dt class="tit"><label><b>返佣条件设置</b></label></dt></dl>
            <dl class="row">
                <dt class="tit">
                    <label>分佣未完成时</label>
                </dt>
                <dd class="opt">
                    <select name="pattern" id="distribut_pattern">
                        <option value="0" <if condition="$config['pattern'] eq 0">selected="selected"</if>>平台</option>
                        <option value="1" <if condition="$config['pattern'] eq 1">selected="selected"</if>>上级</option>
                        <option value="2" <if condition="$config['pattern'] eq 1">selected="selected"</if>>购买者</option>
                    </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">分佣规则</dt>
                <dd class="opt">
                    <input type="radio" name="maid_time" value="0" <if condition="$config[maid_time] eq 0">checked="checked"</if>>订单支付产生分佣 &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="maid_time" value="2" <if condition="$config[maid_time] eq 2">checked="checked"</if>>确认发货产生分佣 &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="maid_time" value="1" <if condition="$config[maid_time] eq 1">checked="checked"</if>>确认收货产生分佣 &nbsp;&nbsp;&nbsp;&nbsp;
                    <!--<input type="radio" name="condition" value="2" <if condition="$config[condition] eq 2">checked="checked"</if>>需提交申请审核 &nbsp;&nbsp;&nbsp;&nbsp;-->
                    <p class="notic">订单支付产生分佣: 佣金根据订单支付时间进行(分成时间返佣)<br/>确认收货产生分佣: 佣金根据订单确认收货时间进行(分成时间返佣)</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">是否开启运费分佣</dt>
                <dd class="opt">
                    <input type="radio" name="maid_time" value="0" <if condition="$config[maid_time] eq 0">checked="checked"</if>>开启 &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="maid_time" value="1" <if condition="$config[maid_time] eq 1">checked="checked"</if>>不开启 &nbsp;&nbsp;&nbsp;&nbsp;
                    <!--<input type="radio" name="condition" value="2" <if condition="$config[condition] eq 2">checked="checked"</if>>需提交申请审核 &nbsp;&nbsp;&nbsp;&nbsp;-->
                    <p class="notic">推荐（不需要）</p>
                </dd>
            </dl>
            </div>
            <div class="bot">
                <input type="hidden" name="inc_type" value="{$inc_type}">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="adsubmit()">确认提交</a>
            </div>
        </div>
    </form>
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script>
    $('#distribut_pattern').change(function(){
        if($(this).val() == 1)
            $('#distribut_order_rate').show();
        else
            $('#distribut_order_rate').hide();
    });

    function adsubmit(){
        var distribut_first_rate  = $.trim($('#distribut_first_rate').val());
        var distribut_second_rate = $.trim($('#distribut_second_rate').val());
        var distribut_third_rate  = $.trim($('#distribut_third_rate').val());

        var rate = parseInt(distribut_first_rate) + parseInt(distribut_second_rate) + parseInt(distribut_third_rate);
        if(rate > 100)
        {
            layer.msg('三个分销商比例总和不得超过100%', {icon: 2,time: 2000});//alert('少年，邮箱不能为空！');
            // alert('三个分销商比例总和不得超过100%');
            return false;
        }

        $('#handlepost').submit();
    }

    function qr_back_call_back(fileurl_tmp)
    {
      $("#qr_back").val(fileurl_tmp);
      $("#qr_back_a").attr('href', fileurl_tmp);
      $("#qr_back_i").attr('onmouseover', "layer.tips('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});");
    }
    function qr_big_back_call_back(fileurl_tmp)
    {
      $("#qr_big_back").val(fileurl_tmp);
      $("#qr_big_back_a").attr('href', fileurl_tmp);
      $("#qr_big_back_i").attr('onmouseover', "layer.tips('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});");
    }
</script>
</body>
</html>